package com.threads;

import com.dataProcess.Matter;
import com.enetiy.Areaip;
import com.enetiy.Userinfo;
import com.operation.NET;
import com.service.AreaIpService;
import com.service.DealService;
import com.service.MapService;
import com.util.Log4gUtil;
/**
 * 网络下线线程
 * @author hzy
 *
 */
public class NetoutThread  implements Runnable{  
		
		public Userinfo userinfo;
		public String account;
		public DealService dealService;
		public MapService mapService;
		public AreaIpService areaIpService;
		public int userid;
		public String callid;
		public String token;
		
	  public NetoutThread(Userinfo userinfo, String account,
			  MapService mapService,DealService dealService, AreaIpService areaIpService, int userid, String callid, String token) {
			super();
			this.userinfo = userinfo;
			this.account = account;
			this.dealService = dealService;
			this.mapService = mapService;
			this.userid = userid;
			this.callid = callid;
			this.token = token;
			this.areaIpService = areaIpService;
		}

	public NetoutThread() {
		super();
	}

	public void run(){  
		  	NET net = new NET();
		  	
		 String areaip;
		try {
			
			areaip = areaIpService.selectAreaip(userinfo.getArea().getId()).getPublicIp();
			Log4gUtil.Info("accountEnroll", userid+"", "IP地址:", userinfo.getUserIp(), "", token);
			int outnet = net.netIntercept(userinfo.getArea().getId(),userinfo.getUserIp(),userinfo.getArea().getNetOut(),
					areaip,userinfo.getUserMac(),userid,account,callid,token,"");
			if(outnet==1){
				userinfo.setNetOnline(0);
				Matter matter = new Matter();
				matter.feeYue(dealService, mapService,userid, net.time,callid,token,net.server_type,net.mac_type,net.protectid,net.orderid);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	   
}
